package com.bigchun.woodhunter;


import android.os.Bundle;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Toast;
//商城

public class WebviewForXieyiActivity extends BaseActivity {


    private WebView webview;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_webview);
        initView();
        initData();
        initListener();

    }


    protected void initView() {
        webview = findViewById(R.id.webview);
        String url = getIntent().getStringExtra("url");


        WebSettings webSettings = webview.getSettings(); //支持缩放，默认为true。
        webSettings.setUseWideViewPort(true); // 缩放至屏幕的大小 webSettings
        webSettings.setLoadWithOverviewMode(true); //设置默认编码
        webSettings.setDefaultTextEncodingName("utf-8"); ////设置自动加载图片
        webSettings.setLoadsImagesAutomatically(true);
        webSettings.setJavaScriptEnabled(true);// 设置可以运行JS脚本
        webSettings.setSupportZoom(false);// 用于设置webview放大
        webSettings.setBuiltInZoomControls(false);

        webview.setWebViewClient(new WebViewClient() {
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                view.loadUrl(url);
                return true;
            }

            @Override
            public void onPageFinished(WebView view, String url) {
                super.onPageFinished(view, url);
                //在这里执行你想调用的js函数

            }
        });
        //3、 加载需要显示的网页
        webview.loadUrl(url);
//        webview.loadUrl("https://d-fubang.bigchun.com/h5/#/xieyi");
//        webview.loadUrl("http://www.baidu.com/");

    }


    protected void initData() {

    }


    protected void initListener() {

    }


    public final void showLongToast(final String msg) {
        this.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_LONG).show();
            }
        });
    }


}
